package com.blb.io;

import java.io.Serializable;

public class Student implements Serializable,Cloneable {

    private String number;
    private String name;
    private Integer age;
    private Address address = new Address("中国","武汉","光谷大道10001号");

    public Student(String number, String name, int age) {
        this.number = number;
        this.name = name;
        this.age = age;
    }

    public Student() {
    }

    public void sayHi(){
        System.out.println("你好，我是" + name +" 我住在" + address);
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "number='" + number + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        Student stu = (Student) super.clone();
        Address address = (Address) stu.getAddress().clone();
        stu.setAddress(address);
        return stu;
    }
}
